﻿using System.Collections.Generic;
using System.IO;
using WebMonitor.Http;

namespace WebMonitor {
    public class ResourceController : Controller {
        private string resourceName;

        public override string ViewName {
            get { return string.Format("{0}.Resources.{1}", GetType().Assembly.FullName.Split(',')[0], resourceName); }
        }

        public override string FillResponseTemplate(IDictionary<string, object> viewParams) {
            using (var stream = GetType().Assembly.GetManifestResourceStream(ViewName))
            using (var sr = new StreamReader(stream)) {
                return sr.ReadToEnd();
            }
        }

        public override IDictionary<string, object> Execute(IHttpContext context) {
            resourceName = context.Request.QueryString["f"];
            return new Dictionary<string, object>();
        }
    }
}